home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / ld / testsuite / ld-srec / sr3.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-04  |  973 b   |  81 lines

  1. // This file is compiled and linked into the S-record format.
  2.  
  3. #define FOO_MSG_LEN 80
  4.  
  5. class Foo {
  6.     static int foos;
  7.     int i;
  8.     const len = FOO_MSG_LEN;
  9.     char message[len];
  10. public:
  11.     static void init_foo ();
  12.     static int nb_foos() { return foos; }
  13.     Foo();
  14.     Foo( char* message);
  15.     Foo(const Foo&);
  16.     Foo & operator= (const Foo&);
  17.     ~Foo ();
  18. };
  19.  
  20. static Foo static_foo( "static_foo");
  21.  
  22. int
  23. main ()
  24. {
  25.   Foo automatic_foo( "automatic_foo");
  26.   return 0;
  27. }
  28.  
  29. extern "C" {
  30. int
  31. __main ()
  32. {
  33. }
  34.  
  35. int
  36. __builtin_delete ()
  37. {
  38. }
  39.  
  40. int
  41. __builtin_new ()
  42. {
  43. }
  44. }
  45.  
  46. int Foo::foos = 0;
  47.  
  48. void Foo::init_foo ()
  49. {
  50.   foos = 80;
  51. }
  52.  
  53. Foo::Foo ()
  54. {
  55.   i = ++foos;
  56. }
  57.  
  58. Foo::Foo (char* msg)
  59. {
  60.   i = ++foos;
  61. }
  62.  
  63. Foo::Foo (const Foo& foo)
  64. {
  65.   i = ++foos;
  66.   for (int k = 0; k < FOO_MSG_LEN; k++)
  67.     message[k] = foo.message[k];
  68. }
  69.  
  70. Foo& Foo::operator= (const Foo& foo)
  71. {
  72.   for (int k = 0; k < FOO_MSG_LEN; k++)
  73.     message[k] = foo.message[k];
  74.   return *this;
  75. }
  76.  
  77. Foo::~Foo ()
  78. {
  79.   foos--;
  80. }
  81.